<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/assets/font/iconfont.css">
    <link rel="stylesheet" href="./css/base.css">
</head>
<body>
    <div class="app" id="app">
        <search-bar></search-bar>
        <div class="type-list">
            <div class="type-item">
                <div class="title-box">
                    <span class="title">全网查询</span>
                    <span class="more">
                        更多
                        <i class="iconfont icon-right"></i>
                    </span>
                </div>
                <div class="list-film">
                    <!-- 在子组件标签上绑定的属性，如果不被props拦截，除了会记录在$attrs属性上，也会直接传递到子组件标签的根元素上 -->
                    <film-item class="list-item" v-for="film in films" :key="film.filmId" :film="film"></film-item>
                </div>
            </div>
        </div>
    </div>
    <script type="module">
         import axios from "/assets/axios/axios.js";
       import { createApp } from "/assets/vue3/vue.esm-browser.js";
        import SearchBar from "./components/SearchBar.js";
        import FilmItem from "./components/FilmItem.js";

        createApp({
            components: {
                SearchBar,FilmItem
            },
            data() {
                return {
                    films:[]
                }
            },
            methods: {
                async loadListData() {
                    try {
                        let { data } = await axios.get("http://127.0.0.1:3000/public/films",{
                            params:{
                                pageSize:11
                            }
                        })
                        this.films = data.data
                    } catch (error) {
                        console.log(error)
                        alert("请求失败")
                    }
                }
            },
            created () {
                this.loadListData();
            },
        }).mount("#app")
    </script>
</body>
</html>